// TOWN SCRIPT
//    Town 5: Ingusi

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	set_name(6,"Sado");
	set_name(15,"Goudon");	
	set_name(25,"Woll");	
	set_state_continue(11);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate 10;
	block_entry(1);
	reset_dialog_preset_options(5);
	choice = run_dialog(0);
	if (choice == 2) {
		move_to_new_town(6,23,25);
		end();
		}
break;

beginstate 11;
	if (get_flag(100,0) < 4)
		set_state_continue(23);
	if ((get_flag(100,0) >= 4) && (get_flag(100,0) < 12))
		set_state_continue(12);
	if (get_flag(100,0) >= 12)
		set_state_continue(26);		
break;

beginstate 12;
	flip_terrain(27,33);
	flip_terrain(27,34);
	flip_terrain(27,35);
	flip_terrain(28,59);
	flip_terrain(29,59);
	set_state_continue(23);
break;

beginstate 13;
	if (get_flag(5,9) == 250)
		end();
	message_dialog("Wooden gates seal off a part of the city. Warriors are practicing and training beyond.","");
	set_flag(5,9,250);
break;

beginstate 14;
	reset_dialog();
	add_dialog_str(0,"A white marble altar stands amid a calm pool. Many symbols and glyphs are carved upon it, as though describing some traditional ritual. It's so long and obtuse, however, that you couldn't hope to translate it with the greatest mage lore.",0);
	add_dialog_str(1,"You could still pray at it. The effects might not be so great, but you should still get some benefits.",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Pray.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(15);
break;

beginstate 15;
	if (get_flag(5,0) >= 1)
		set_state_continue(18);
	set_state_continue(16);
break;

beginstate 16;
	set_flag(5,0,1);
	set_state_continue(17);
break;

beginstate 17;
	message_dialog("You feel more skilled!","");
	i = 0;
	while (i < 6) {
		if (char_ok(i)) {
			change_pc_skill_pts(i,8);
			}
		i = i + 1;
		}
break;

beginstate 18;
	message_dialog("Nothing seems to happen this time.","");
break;

beginstate 19;
	if (get_flag(100,0) == 11)
		set_state_continue(20);
break;

beginstate 20;
	reset_dialog();
	add_dialog_str(0,"As soon as you walk into the enclosure of Ingusi, you fell the air isn't quite right. With but a faint rustling, guards seal off the exit. On both sides the sentinels stand on full alert, weapons drawn. A cloaked figure walks up to you.",0);
	add_dialog_str(1,"_Ah. Our mercenary friends have arrived._ The voice is still recognizable, but Rauling's tone has suddenly taken on a flavor alien to you. _Returning from various heinous crimes. You have been requested as prisoners to the Falcon._",0);
	add_dialog_str(2,"There's no chance for a fight here, outnumbered a thousand to one. You're easily captured. Answering no questions, the guards bind you and throw you in prison carts, heading out the city. No one speaks to you on the journey north.",0);
	add_dialog_str(3,"The endless clatter of the carts shakes you to unrestful sleep.",0);
	add_dialog_str(4," * * *",0);
	add_dialog_str(5,"You wake up in a cold prison cell. The bruises from your journey here are still painful. You remember vaguely seeing your destination from a distance. This must be Hengest, stronghold of the Falcon. But... why?",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_state_continue(21);
break;

beginstate 21;
	set_flag(100,0,12);
	set_state_continue(24);
break;

beginstate 23;
	if (get_flag(105,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"Ingusi. Hronesnaess. The Whale's Cape. You've heard of it before, but the first sight of it does not fail to amaze you.",0);
	add_dialog_str(1,"Twisting spires of black rock rise to the skies over the city. Sloped balconies provide distorted points of view. Gaping windows stare down with menace. A thin line of black smoke rises from the highest tower.",0);
	add_dialog_str(2,"The entire city has been built above the waters themselves. Arching bridges provide the means for transportation about. Silent sentinels and halberdiers stand guard everywhere. Each stares at you tensely as you pass.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(105,0,250);
break;

beginstate 24;
	change_outdoor_location(1,0,23,13);
	block_entry(1);
		move_to_new_town(18,29,38);
		end();
break;

beginstate 25;
	if (get_flag(190,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"From the platform of the lighthouse, you gaze out over the eastern seas until it falls down and away at the horizon. The sun shines down brightly, its light glaring off the surface. Small black shapes glide upon it, perhaps ships or birds.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(190,0,250);
break;

beginstate 26;
	make_town_hostile();
	flip_terrain(28,59);
	flip_terrain(29,59);
break;

beginstate 27;
	if (in_horse() >= 0){
	print_str_color("You must dismount before you can enter the city",1);
	block_entry(1);
	}
break;